<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/static/commons/taglibs.jsp"%>
<%@ include file="/static/commons/meta.jsp"%>
<html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 	<title>${title }</title>
	<!--自定义index样式-->
	<link rel="stylesheet" href="${ctx }/static/styles/basic/basic.css" ></link>
	<link rel="stylesheet" href="${ctx }/static/styles/edit/tableStyle.css"></link>
	<!--js库-->
	<%@ include file="/static/commons/jquery-easyui.jsp" %>
	<script type="text/javascript" src="${ctx}/static/widgets/easyui/plugins/jquery.draggable.js"></script>
	<script type="text/javascript" src="${ctx}/static/widgets/easyui/plugins/jquery.droppable.js"></script>
	<script type="text/javascript" src="${ctx}/static/widgets/easyui/plugins/jquery.tree.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/set_select.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/WdatePicker/WdatePicker.js"></script>
	<style type="text/css">
		body{overflow: hidden; padding: 8px;}
	</style>
  </head>
  
  <body>
  		<c:set var="disabled" value=""></c:set>
  		<c:set var="ifSelect" value=""></c:set>
  		<c:if test="${not empty view}">
  			<c:set var="disabled" value="disabled"></c:set>
  			<c:set var="ifSelect" value="false"></c:set>
  		</c:if>
  		<form id="editForm" action="${ctx}/taskAssign/save" method="post">
  			<input type="hidden" id="orderId" name="p_orderId" ></input>
  			<input type="hidden" id="assignId" name="p_assignId" ></input>
  			<input type="hidden" value="1" id="orderType" name="p_orderType" ></input>
  			<table class="table-ltr">
  				<tbody>
					<tr>
						<td>订单号：</td>
						<td>
							<input type="text" id="order_id" class="wd170" disabled maxLength="20" style="width: 100%;"></input>
						</td>
						<td>用户单位：</td>
						<td>
							<input type="text" id="cust_name" class="wd170 " disabled maxLength="20" style="width: 100%;" ></input>
						</td>
					</tr>
					<tr>
						<td class="non-empty">组长：</td>
						<td>
							<select class="normal_select wd170" id="leaderId" name="p_leaderId" style="width:99%;" ${disabled }>
								<option value="">--请选择--</option>
								<c:forEach items="${leaderList}" var="v">
									<option value="${v.user_id }">${v.user_name }</option>
								</c:forEach>
							</select>
						</td>
						<td class="non-empty">完成时间：</td>
						<td>
							<input type="text" id="completeDate" name="p_completeDate" class="Wdate wd170" ${disabled } style="width: 100%;" onFocus="WdatePicker()" ></input>
						</td>
					</tr>
				</tbody>
  			</table>
  			<table id="userTab" class="table-ltr">
  				<caption>
 						详细信息
  				</caption>
  				<tbody>
					<tr>
						<td>气瓶：</td>
						<td>
							<input type="text" id="count1" class="wd170" disabled style="width: 100%;" value="0" ></input>
						</td>
						<td class="non-empty">检测人员：</td>
						<td style="width: 313px">
							<input type="hidden" id="userId1" name="p_userId1" ></input>
							<input type="text" id="userName1" readonly="readonly" name="p_userName1"
								class="wd170" ${disabled } style="width: 100%;"></input>
						</td>
					</tr>
					<tr>
						<td>空呼：</td>
						<td>
							<input type="text" id="count2" class="wd170" disabled style="width: 100%;" value="0" ></input>
						</td>
						<td class="non-empty">检测人员：</td>
						<td>
							<input type="hidden" id="userId2" name="p_userId2" ></input>
							<input type="text" id="userName2" readonly="readonly" name="p_userName2"
								class="wd170 " ${disabled } style="width: 100%;"></input>
						</td>
					</tr>
					<tr>
						<td>气体检测仪：</td>
						<td>
							<input type="text"  id="count3" class="wd170" disabled style="width: 100%;" value="0" ></input>
						</td>
						<td class="non-empty">检测人员：</td>
						<td>
							<input type="hidden" id="userId3" name="p_userId3" ></input>
							<input type="text" id="userName3" readonly="readonly" name="p_userName3"
								class="wd170" ${disabled } style="width: 100%;" ></input>
						</td>
					</tr>
				</tbody>
  			</table>
        </form>
        <script type="text/javascript">
	        $(function(){
	        	<c:forEach items="${list }" var="li" varStatus="i">
	  				<c:if test="${i.index == 0 }">
	  					$('#orderId').val('${li.order_id }');
	  					$('#assignId').val('${li.assign_id }');
	  					$('#order_id').val('${li.order_id }');
	  					$('#cust_name').val('${li.cust_name }');
	  					$('#leaderId').val('${li.leader_id }');
	  					$('#completeDate').val('${li.complete_date }');
	  				</c:if>
	  					$('#count${li.deviceType }').val('${li.nums }');
						$('#userId${li.deviceType }').val('${li.user_id }');
						$('#userName${li.deviceType }').val('${li.user_name }');
						$('#userName${li.deviceType }').attr('data-count','${li.nums }');
	  			</c:forEach>
  			
	        	$('input[readonly]').each(function(){
	        		var count = $(this).data('count');
	        		if(count>0){
	        			var userType = this.id.slice(8);
	        			$(this).on('click focus', function(){
	        				var win = parent.document.getElementById('tabFrame03.03.01').contentWindow;
	                		win.getUserList(userType);
	        			}).css('cursor','pointer');
	        		}
	        	});
	        });
        
        	function addLeader(){
        		var leaderId = $('#leaderId').val();
        		$('#leaderId').html('<option value="">--请选择--</option>');
				var ids = $('#userTab tbody').find(':hidden').map(function(){return $(this).val();}).get().join(",").split(',');
				var names = $('#userTab tbody').find(':hidden').siblings('input').map(function(){return $(this).val();}).get().join("，").split('，');
				$.unique(ids.sort());
				$.unique(names.sort());
				for(var i=0; i<ids.length; i++){
					if(''!=ids[i]){
						$('#leaderId').append('<option value="'+ ids[i] +'">'+ names[i] +'</option>');
					}
				}
				$('#leaderId').val(leaderId);
        	}
        </script>
  </body>
</html>